<@>layout("/common/default.html"){
<div style="padding: 10px">
    <form class="layui-form" id="newuser-data">
        <div class="layui-form-item">
            <label class="layui-form-label">账号：</label>
            <div class="layui-input-block">
                <input type="text" lay-verify="required" class="layui-input" id="username" name="username"
                       value="${user.username}" style="width: 95%">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">名称：</label>
            <div class="layui-input-block">
                <input type="text" lay-verify="required" class="layui-input" id="name" name="name" value="${user.name}"
                       style="width: 95%">
            </div>
        </div>
        <input type="hidden" name="id" value="${user.id}">
        <button type="button" lay-submit=""lay-filter="saveUser" class="layui-btn" style="position: relative;left: 40px">提交</button>
    </form>
</div>
<script>
    layui.use("form", function () {
        var form = layui.form;
        form.on('submit(saveUser)', function () {
            $.cajax('${ctxPath}/ajax/userpermission/user/save', $('#newuser-data').serialize(), function (r) {
                var code = r.code;
                var msg = r.msg;
                if (code == '1') {
                    $.msg(msg, function () {
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                        parent.layui.table.reload('user-list');
                    }, code);
                } else {
                    $.msg(msg, function () {
                    }, 2);
                }
            });
        })
    });

</script>
<@>}